from bot import Bot
from bots_common import *


class Bot_Biggest_Smart_A(Bot):

    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.name = 'BiggestSmartA'

    def bot_give_card(self, msg):
        hand = msg.get('hand')
        rows = msg.get("board")
        weight=list(filter(lambda x: x < 51, hand))
        maxhand = max(hand)
        minhand = min(hand)
        betcard = maxhand
        rowends = list(map(lambda x: x[-1], rows))
        if len(weight) > len(hand)/2:
            betcard = min(weight)


        msg = self.give_card(betcard)
        self.send_msg(msg)
        return betcard

    def bot_select_row(self, msg):
        print('about to select row')
        rows = msg.get("rows")
        index = lowest_penalty_row_index(rows)[0]
        answer = self.choose_row(index)
        self.send_msg(answer)
